/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2012-2019. All rights reserved.
 */

package com.huawei.idea.share;

import android.content.Context;
import android.widget.Toast;

import com.huawei.idea.ideasharesdk.jni.JniCallbackError;

/**
 * 错误码提示
 *
 * @author w00415409
 * @since 2021/1/7
 */
public class ShowErrorUtil {
    public static void showErrorMsg(Context context, int errCode) {
        String txt = "未知错误：" + errCode;
        if (errCode == JniCallbackError.IDEA_SHARE_DISCOVER_ERROR.ordinal()) {
            txt = "设备发现错误";
        }
        if (errCode == JniCallbackError.IDEA_SHARE_CONNECT_ERROR.ordinal()) {
            txt = "连接失败，检查主机是否在同一网络";
        }
        if (errCode == JniCallbackError.IDEA_SHARE_DISCONNECT_ERROR.ordinal()) {
            txt = "断开连接错误";
        }
        if (errCode == JniCallbackError.IDEA_SHARE_SHARE_PLAY_ERROR.ordinal()) {
            txt = "启动投屏错误";
        }
        if (errCode == JniCallbackError.IDEA_SHARE_SHARE_STOP_ERROR.ordinal()) {
            txt = "停止投屏错误";
        }
        if (errCode == JniCallbackError.IDEA_SHARE_GET_REMOTE_SERVICE_STATUS_ERROR.ordinal()) {
            txt = "遥控器参数查询结果错误";
        }
        if (errCode == JniCallbackError.IDEA_SHARE_SET_REMOTE_MIC_MUTE_ERROR.ordinal()) {
            txt = "打开\\关闭麦克风结果错误";
        }
        if (errCode == JniCallbackError.IDEA_SHARE_SET_REMOTE_SPEAKER_VOLUME_ERROR.ordinal()) {
            txt = "调节扬声器音量结果错误";
        }
        if (errCode == JniCallbackError.IDEA_SHARE_SET_REMOTE_SPEAKER_MUTE_ERROR.ordinal()) {
            txt = "打开\\关闭扬声器结果错误";
        }
        if (errCode == JniCallbackError.IDEA_SHARE_SET_REMOTE_CAMERA_MUTE_ERROR.ordinal()) {
            txt = "打开\\关闭摄像机结果错误";
        }
        if (errCode == JniCallbackError.IDEA_SHARE_LEAVE_CONFERENCE_ERROR.ordinal()) {
            txt = "离开会议结果错误";
        }
        if (errCode == JniCallbackError.IDEA_SHARE_END_CONFERENCE_ERROR.ordinal()) {
            txt = "结束会议结果错误";
        }
        if (errCode == JniCallbackError.IDEA_SHARE_GET_SDK_LATEST_VERSION_ERROR.ordinal()) {
            txt = "获取SDK最新版本";
        }
        if (errCode == JniCallbackError.IDEA_SHARE_PROCESS_CONNECTING_ERROR.ordinal()) {
            txt = "正在处理连接请求";
        }
        if (errCode == JniCallbackError.IDEA_SHARE_IN_CONNECTION_ERROR.ordinal()) {
            txt = "客户端已处于连接";
        }
        if (errCode == JniCallbackError.IDEA_SHARE_PROJECTION_CODE_ERROR.ordinal()) {
            txt = "投影码错误 数字+字母组合";
        }
        if (errCode == JniCallbackError.IDEA_SHARE_AUTH_ERROR.ordinal()) {
            txt = "连接失败，投屏码错误或投屏码过期，请重新输入";
        }
        if (errCode == JniCallbackError.IDEA_SHARE_CLIENT_IS_LOCKED_ERROR.ordinal()) {
            txt = "客户端被锁定";
        }
        if (errCode == JniCallbackError.IDEA_SHARE_CONNECT_BUSY_ERROR.ordinal()) {
            txt = "终端忙碌";
        }
        if (errCode == JniCallbackError.IDEA_SHARE_CONNECT_UPDATING_ERROR.ordinal()) {
            txt = "终端正在升级";
        }
        if (errCode == JniCallbackError.IDEA_SHARE_WEB_DENY_ERROR.ordinal()) {
            txt = "WEB被禁用";
        }
        if (errCode == JniCallbackError.IDEA_SHARE_NO_COMMON_DATA_CAP_ERROR.ordinal()) {
            txt = "和客户端没有辅流公共能力";
        }
        if (errCode == JniCallbackError.IDEA_SHARE_GET_TOKEN_FAILED_ERROR.ordinal()) {
            txt = "获取辅流令牌失败";
        }
        if (errCode == JniCallbackError.IDEA_SHARE_LOW_BANDWIDTH_ERROR.ordinal()) {
            txt = "带宽过低，无法发送辅流";
        }
        if (errCode == JniCallbackError.IDEA_SHARE_CONF_NO_DATA_CAP_ERROR.ordinal()) {
            txt = "会议无辅流能力";
        }
        if (errCode == JniCallbackError.IDEA_SHARE_MULTI_CONNECT_BUSY_ERROR.ordinal()) {
            txt = "终端忙，请稍后再试";
        }
        if (errCode == JniCallbackError.IDEA_SHARE_EUA_AUTH_ERROR.ordinal()) {
            txt = "EUA鉴权失败";
        }
        if (errCode == JniCallbackError.IDEA_SHARE_EUA_IS_LOCKED_ERROR.ordinal()) {
            txt = "客户端被锁定，请稍后再试";
        }
        if (errCode == 100) {
            txt = "当前环境不支持开启音频";
        }
        if (errCode == -1) {
            txt = "缺少投屏权限";
        }
        Toast.makeText(context, txt, Toast.LENGTH_SHORT).show();
    }
}
